#include "myeventfilter.h"
#include <QKeyEvent>
#include <QDebug>

myEventFilter::myEventFilter(QObject *parent) : QObject(parent)
{
}
bool myEventFilter::eventFilter(QObject *watched, QEvent *event)
{
    if(event->type() == QEvent::KeyPress) { //按下操作
        QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
        if(keyEvent->key() == Qt::Key_A) {
            qDebug() << "事件过滤器处理：键入 A";
            return true;//处理事件，不再向后传递
        }
    }
    return QObject::eventFilter(watched, event); //继续处理其他事件
}
